<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>客户列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-btn+.layui-btn{
            margin-left: 0;
        }
    </style>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>{$nav}</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3" style="line-height:30px"></i></a>
    </div>
    <div class="x-body x-admin">
        
      <xblock>
        <a href="{:url('admin/ClientReview/reviewList')}" class="layui-btn layui-btn-primary">全部</a>
        <a href="{:url('admin/ClientReview/reviewList')}/status/1" class="layui-btn layui-btn-primary">已回访</a>
        <a href="{:url('admin/ClientReview/reviewList')}/status/-1" class="layui-btn layui-btn-primary">未回访</a>
        <div class="layui-card-body" style="padding-left: 0;float:left;padding-left:20px;padding-top:0;">
          <form class="layui-form layui-col-space5" action="{:url('admin/ClientReview/reviewList')}/status/{$status}" method="get">
              <div class="layui-inline layui-show-xs-block">
                  <input style="width:260px;" type="text" name="keywords" id="search" value="{:input('keywords')}" placeholder="请输入客户姓名、赛事名称、联系方式" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-inline layui-show-xs-block">
                  <button class="layui-btn" id="search-btn"><i class="layui-icon"></i></button>
              </div>
          </form>
        </div>
        <span class="x-right" style="line-height:40px">共有数据：{$count}条</span>
        
      </xblock>
      <div class="layui-table-body layui-table-main" style="width: 100%;">
      <table class="layui-table layui-form">
        <thead>
          <tr>
            <th>ID</th>
            <th>赛事名称</th>
            <th>地区(市、县)</th>
            <th>比赛时间</th>
            <th>营销</th>
            <th>签单日期</th>
            <th>回访状态</th>
            <th>回访日期</th>
            
            <th style="text-align: center;">操作</th>
        </thead>
        <tbody>
          {volist name="list" id="client"}
          <tr>
            <td>{$client.id}</td>
            <td>{$client.activity}</td>
            <td>{$client.address}</td>
            <td>{$client.activity_time}</td>
            <td>{$client.aname}</td>
            <td>{$client.qiandan_time|date="Y-m-d",###}</td>
            
            <td>{if condition="$client.review_status eq 1"}<button class="layui-btn layui-btn-sm layui-btn-primary layui-border-blue">已回访</button>{else}<button class="layui-btn layui-btn-sm layui-btn-primary layui-border-black">未回访</button>{/if}</td>
            <td>{if condition="$client.review_time"}{$client.review_time|date="Y-m-d",###}{/if}</td>
            <td class="td-manage" style="text-align: center;">
                {if condition="$client['status'] eq 4"}
                {if condition="$client['review_status'] eq 1"}
                <a title="回访结果" class="layui-btn layui-btn-normal layui-btn-xs" onclick="x_admin_show('{$client.activity} 的 回访结果','{:url('admin/ClientReview/view')}/client_id/{$client.id}')" href="javascript:;">
                    回访结果
                </a>
                {else}
                <a title="回访" class="layui-btn layui-btn-normal layui-btn-xs" onclick="x_admin_show('回访 {$client.activity}','{:url('admin/ClientReview/edit')}/client_id/{$client.id}')"  href="javascript:;">
                    回访
                </a>
                {/if}
                {/if}
            </td>
          </tr>
          {/volist}
        </tbody>
      </table>
    </div>
      <div class="page">
        <div>
          {$list->render()}
        </div>
      </div>
    </div>

    <script>
      layui.use(['form','layer'], function(){
        form = layui.form,
        layer = layui.layer;
        /*管理员开关*/
        form.on('switch(status)', function(data){
          var obj=data.elem;
          var id = data.elem.id;
          var status = data.value;
          $.ajax({
              type:'POST',
              dataType:'json',
              data:{status:status,id:id},
              url:"{:url('Admin/changeStatus')}",
              success:function(o){
                if(o.icon == 1){
                  $(obj).attr('value',1);
                }else{
                  $(obj).attr('value',0);
                }
                layer.msg(o.msg,{icon: o.icon,time:1000});
              }
            });
        });
        
        //监听提交
        form.on('submit(baoA)', function(data){
                var client_id = $(this).attr('lay-id');
                layer.confirm('确定将该客户进行保A吗？', {icon: 3, title:'保A操作'}, function(index){
                    //do something
                    $.ajax({
                        type:'POST',
                        dataType:'json',
                        data:{client_id:client_id},
                        url:"{:url('Client/baoA')}",
                        success:function(obj){
                          layer.msg(obj.msg, {icon: obj.icon,time: 2000},function(){
                            // 获得frame索引
                            // var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            // parent.layer.close(index);
                            // 可以对父窗口进行刷新 
                            //x_admin_father_reload();
                            location.reload();
                          });
                        }
                    });
                  layer.close(index);
                });
            return false;
        });

        form.on('submit(cancel)', function(data){
                var client_id = $(this).attr('lay-id');
                layer.confirm('确定将该客户进行回收吗？', {icon: 3, title:'回收操作'}, function(index){
                    //do something
                    $.ajax({
                        type:'POST',
                        dataType:'json',
                        data:{client_id:client_id,{if condition="$lst eq 'lst2'"}type:2{/if} },
                        url:"{:url('Client/cancelClient')}",
                        success:function(obj){
                          layer.msg(obj.msg, {icon: obj.icon,time: 2000},function(){
                            // 获得frame索引
                            // var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            // parent.layer.close(index);
                            // 可以对父窗口进行刷新 
                            //x_admin_father_reload();
                            location.reload();
                          });
                        }
                    });
                  layer.close(index);
                });
            return false;
        });
        
      });

    </script>
  </body>

</html>